<template>
  <div>

    <el-form :inline="true" :model="user" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input v-model="user.username" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item label="公司名">
        <el-input v-model="user.gzname" placeholder="公司名"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="user.phone" placeholder="手机号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="list">查询</el-button>
      </el-form-item>
    </el-form>

    <template>
      <el-table
          :data="tableData"
          border
          style="width: 100%">
        <el-table-column
            fixed
            prop="cname"
            label="用户中文名"
            width="150">
        </el-table-column>
        <el-table-column
            prop="username"
            label="用户英文名"
            width="120">
        </el-table-column>
        <el-table-column
            prop="phone"
            label="手机号"
            width="120">
        </el-table-column>
        <el-table-column
            prop="zw"
            label="职位"
            width="120">
        </el-table-column>
        <el-table-column
            prop="gzname"
            label="公司中文名"
            width="300">
        </el-table-column>
        <el-table-column
            prop="gyname"
            label="公司英文名"
            width="120">
        </el-table-column>
        <el-table-column
            prop="address"
            label="公司地址"
            width="120">
        </el-table-column>
        <el-table-column
            prop="email"
            label="邮箱"
            width="120">
        </el-table-column>
        <el-table-column
            prop="daddress"
            label="地图名称"
            width="120">
        </el-table-column>
        <el-table-column
            prop="date"
            label="创建时间"
            width="120">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="操作"
            width="100">
          <template slot-scope="scope">
            <el-button @click="del(scope.row.id)" type="text" size="small">删除</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </template>

    <el-pagination
        @current-change="goPage"
        :page-size="10"
        layout="total, prev, pager, next"
        :total="total">
    </el-pagination>

  </div>
</template>

<script>
export default {
  name: "ListView",
  data() {
    return {
      tableData:[],
      pageNum:"",
      total:0,
      user:{}
    }
  }, methods: {
    del(id){
      this.axios.post("ttp://localhost:9999/user/del?id="+id).then(res=>{
        if (res.data.code==200){
          this.$message.success(res.data.msg);
        }else {
          this.$message.error(res.data.msg);
        }
      })
    },
    goPage(page){
      this.pageNum=page;
      this.list();
    },
    list(){
      this.axios.post("http://localhost:9999/user/list?pageNum="+this.pageNum,this.user).then(res=>{
        this.tableData=res.data.data.list;
        this.total=res.data.data.total;
      })
    }
  }, created() {
    this.list();
  }
}
</script>

<style scoped>

</style>